//
//  YSDirectoryCell.m
//  YSBookRead
//
//  Created by MOLBASE on 2018/11/15.
//  Copyright © 2018年 YangShen. All rights reserved.
//

#import "YSDirectoryCell.h"
#import "YSBookChapterContentModel.h"

@interface YSDirectoryCell ()

@property (weak, nonatomic) IBOutlet UIImageView *separatorImageview;

@property (weak, nonatomic) IBOutlet UIImageView *stateImageView;
@property (weak, nonatomic) IBOutlet UILabel *numberLabel;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;


@end

@implementation YSDirectoryCell

- (void)awakeFromNib {
    [super awakeFromNib];
    UIImage *image = [UIImage imageNamed:@"bookDirectory_separator"];
    self.separatorImageview.image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(image.size.width/2, 0, image.size.width, image.size.height)];
}

- (void)setChapterModel:(YSBookChapterContentModel *)chapterModel {
    _chapterModel = chapterModel;

    if (self.isReadingChapter) {
        self.stateImageView.image = [UIImage imageNamed:@"bookDirectory_selected"];
    } else if (chapterModel.haveCache) {
        self.stateImageView.image = [UIImage imageNamed:@"directory_previewed"];
    } else {
        self.stateImageView.image = [UIImage imageNamed:@"directory_not_previewed"];
    }
    self.numberLabel.text = [NSString stringWithFormat:@"%zi.",self.count];
    self.titleLabel.text = chapterModel.chapterName;
}

@end
